﻿using HelperFromTheSkeleton.Common;
using HelperFromTheSkeleton.Convert;

namespace Authority.Common
{
    public class AuthorityConfig: Config
    {
        private static AuthorityConfigModel? _config;

        /// <summary>
        /// 配置
        /// </summary>
        public static AuthorityConfigModel? ConfigData
        {
            get
            {
                if (_config == null)
                {
                    var configBasePath = AppDomain.CurrentDomain.BaseDirectory;
                    var configPath = Path.Combine(configBasePath, "AuthorityConfig.json");
                    if (File.Exists(configPath))
                    {
                        var configText = File.ReadAllText(configPath);
                        _config = configText.ToObject<AuthorityConfigModel>();
                    }
                }
                return _config;
            }
        }
    }
}